home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 April / april_2001.iso / intercd / root / ^Palm / Utilities / pocketifs / trans_i.txt < prev   
Encoding:
Text File  |  1999-11-24  |  3.5 KB  |  240 lines

  1. Modified:    Wed 24/11/99 09:28
  2.  
  3. PalmPilot Category:    PocketC
  4. /$trans.i
  5. #ifndef trans_i
  6. #define trans_i
  7.  
  8. //trans
  9. #define t_a 0
  10. #define t_b 1
  11. #define t_c 2
  12. #define t_d 3
  13. #define t_e 4
  14. #define t_f 5
  15. #define t_next 6
  16. #define sizeof_t 7
  17.  
  18. pointer NewTrans( 
  19.   float a, float b, float c,float d, 
  20.   float e, float f)
  21. {
  22.     pointer p;
  23.     p = malloc(sizeof_t);
  24.     if (p){
  25.         settype(p,6,'f');
  26.         p[t_a]=a;
  27.         p[t_b]=b;
  28.         p[t_c]=c;
  29.         p[t_d]=d;
  30.         p[t_e]=e;
  31.         p[t_f]=f;
  32.         p[t_next]=0;
  33.     }
  34.     return p;
  35. }
  36.  
  37. DeleteTrans(pointer p)
  38. {
  39.     pointer  t;
  40.     while(p){
  41.       t = p[t_next];
  42.       free(p);
  43.        p=t;
  44.     }
  45. }
  46.  
  47. WriteTransToMemo(pointer p)
  48. {
  49.     do{
  50.         mmputs(
  51.           p[t_a]+"\n"+
  52.           p[t_b]+"\n"+
  53.           p[t_c]+"\n"+
  54.           p[t_d]+"\n"+
  55.           p[t_e]+"\n"+
  56.           p[t_f]+"\n");
  57.         p = p[t_next];
  58.     }while(p);
  59.     mmputs("!\n");
  60. }
  61.  
  62. pointer ReadTransFromMemo()
  63. {
  64.     pointer head,cur;
  65.     string a,b,c,d,e,f;
  66.     a=mmgetl();
  67.     b=mmgetl();
  68.     c=mmgetl();
  69.     d=mmgetl();
  70.     e=mmgetl();
  71.     f=mmgetl();
  72.     head=cur=
  73.       NewTrans(a,b,c,d,e,f);
  74.     a=mmgetl();
  75.     while(cur && a!="!"){
  76.         b=mmgetl();
  77.         c=mmgetl();
  78.         d=mmgetl();
  79.         e=mmgetl();
  80.         f=mmgetl();
  81.         cur[t_next]=
  82.           NewTrans(a,b,c,d,e,f);
  83.         cur=cur[t_next];
  84.         a=mmgetl();
  85.     }
  86.     return head;
  87. }
  88.  
  89. DrawLineTrans(
  90.   pointer cur,
  91.   float a, float b, float c, float d, 
  92.   float e, float f,
  93.   int col)
  94. {
  95.     int x1,y1,x2,y2;
  96.     pointer nxt;
  97.     nxt = cur[p_next];
  98.     x1=cur[p_x]*a+ 
  99.         cur[p_y]*b+e;
  100.     y1=cur[p_x]*c+ 
  101.         cur[p_y]*d+f;
  102.     x2=nxt[p_x]*a+
  103.         nxt[p_y]*b+e;
  104.     y2=nxt[p_x]*c+ 
  105.         nxt[p_y]*d+f;
  106.     line(col,
  107.       x1+centre_x,y1+centre_y,
  108.       x2+centre_x,y2+centre_y);
  109. }
  110.  
  111. DrawShapeTrans(
  112.   pointer cur,
  113.   float a, float b, float c,float d, 
  114.   float e, float f,
  115.   int col)
  116. {
  117.     do{
  118.         DrawLineTrans(cur,
  119.           a,b,c,d,e,f,
  120.           col);
  121.         cur = cur[p_next];
  122.     }while(cur[p_next]);
  123. }
  124.  
  125. #include "pifs_icons.i"
  126.  
  127. Toggle(int mode)
  128. {
  129.     rect(3,160-(mode+1)*10,1,
  130.       159-mode*10,10,
  131.       0);
  132. }
  133.  
  134. pointer GetTrans(pointer head)
  135. {
  136.     float p,q,r,s,e,f;
  137.     float a,b,c,d;
  138.     int oldmode,cx,cy,px,py;
  139.     int mode;
  140.     int lock;
  141.  
  142.     bitmap(160-10,1,ROTATE);
  143.     bitmap(160-20,1,SCALE);
  144.     bitmap(160-30,1,MOVE);
  145.     bitmap(160-40,1,LOCK);
  146.     bitmap(160-50,1,HAPPY);
  147.  
  148.     p=q=0;
  149.     r=s=1;
  150.  
  151.     Toggle(mode);
  152.  
  153.     while(event(1)!=2);
  154.     cy=peny();
  155.     cx=penx();
  156.  
  157.     do{
  158.  
  159.     py=peny();
  160.     if (lock) px=py;
  161.     else px=penx();
  162.  
  163.     if (mode==0){
  164.         q =(float)(py-cy)
  165.           *7/160;
  166.         p =(float)(px-cx)
  167.           *7/160;
  168.     }
  169.     else if (mode==1){
  170.         s = (float)(py-cy)
  171.           /80;
  172.         r = (float)(px-cx)
  173.           /80;
  174.     }
  175.     else{
  176.         e=penx()-cx;
  177.         f=peny()-cy;
  178.     }
  179.  
  180.     a = r * cos(p);
  181.     b = -s * sin(q);
  182.     c = r * sin(p);
  183.     d = s * cos(q);
  184.     DrawShapeTrans(head,
  185.       a, b,  c, d, e, f,
  186.       3);
  187.     if (event(1)==3){
  188.  
  189.         do{
  190.           while(event(1)!=2);
  191.           cx = penx();
  192.           cy = peny();
  193.           if (cy<=10){
  194.             Toggle(mode);
  195.              oldmode=mode;
  196.              mode = (159-cx)/10;
  197.            Toggle(mode);
  198.             if(mode==3){
  199.              lock=!lock;
  200.              mode=oldmode;
  201.              Toggle(mode);     
  202.             }
  203.           }
  204.           else break;
  205.         }while(mode!=4);
  206.  
  207.         if (mode==4){
  208.           Toggle(mode);
  209.           mode = oldmode;
  210.           Toggle(mode);
  211.           if (confirm("Happy?"))
  212.             break;
  213.         }
  214.         if (lock) cx=cy;
  215.         if (mode==0){
  216.             cx = cx - p/7*160;
  217.             cy = cy - q/7*160;
  218.         }
  219.         else if (mode==1){
  220.             cx = cx - r*80;
  221.             cy = cy - s*80;
  222.         }
  223.         else{
  224.             cx=penx()-e;
  225.             cy=peny()-f;
  226.         }
  227.     }
  228.     DrawShapeTrans(head,
  229.       a, b,  c, d, e, f,
  230.       3);
  231.     }while(1);
  232.     DrawShapeTrans(head,
  233.       a, b,  c, d, e, f,
  234.       1);
  235.     Toggle(mode);
  236.     return 
  237.       NewTrans(a, b, c, d, e, f);
  238. }
  239.  
  240. #endif//trans_i